package knowledge.content.type.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

import com.googlecode.jtiger.core.model.BaseIdModel;

/**
 * 内容类别
 * 
 * @author Administrator
 * 
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "KN_CONTENT_TYPES")
public class KNContentType extends BaseIdModel {

	private String name;
	private String descn;
	private KNContentType parent;
	private Set<KNContentType> children = new HashSet<KNContentType>(0);

	@Column(name = "NAME", length = 100)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "DESCN", length = 255)
	public String getDescn() {
		return descn;
	}

	public void setDescn(String descn) {
		this.descn = descn;
	}

	@JsonIgnore
	@ManyToOne
	@JoinColumn(name = "PARENT_ID")
	public KNContentType getParent() {
		return parent;
	}

	public void setParent(KNContentType parent) {
		this.parent = parent;
	}

	@JsonIgnore
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "parent")
	public Set<KNContentType> getChildren() {
		return children;
	}

	public void setChildren(Set<KNContentType> children) {
		this.children = children;
	}

}
